<?php
/**
 * A unique identifier is defined to store the options in the database and reference them from the theme.
 * By default it uses the theme name, in lowercase and without spaces, but this can be changed if needed.
 * If the identifier changes, it'll appear as if the options have been reset.
 */

function optionsframework_option_name() {

	// This gets the theme name from the stylesheet
	$themename = get_option( 'stylesheet' );
	$themename = preg_replace("/\W/", "_", strtolower($themename) );

	$optionsframework_settings = get_option( 'optionsframework' );
	$optionsframework_settings['id'] = $themename;
	update_option( 'optionsframework', $optionsframework_settings );
}


function optionsframework_options() {

	// Show Hide Dropdowns
	$showhide = array(
		'show' => __('Show', 'wpboxes'),
		'hide' => __('Hide', 'wpboxes'),
	);
	
	// Author Box Position
	$abp = array(
		'above' => __('Above Post', 'wpboxes'),
		'below' => __('Below Post', 'wpboxes'),
	);
	
	// Featured Category
	$featured_categories = array();
	$featured_categories_obj = get_categories();
	foreach ($featured_categories_obj as $category) {
		$featured_categories[$category->cat_ID] = $category->cat_name;
	}
	
	/******************* Option Options End **************************/
	$options = array();
	
	/* General Settings */
	$options[] = array(
		'name' => __('General', 'wpboxes'),
		'type' => 'heading');
	
	$options[] = array(
		'name' => __('Use a Image Logo?', 'wpboxes'),
		'desc' => __('Use a Image Logo Instead of Default Text Logo.', 'wpboxes'),
		'id' => 'wpboxes_imagelogo',
		'type' => 'checkbox');

	$options[] = array(
		'name' => __('Upload an Image Logo', 'wpboxes'),
		'desc' => __('Should be exactly 400x120 pixels. Otherwise, it will be resized.<br/>Click "Use Image" button after upload at the upload window', 'wpboxes'),
		'id' => 'wpboxes_logo_uploader',
		'class' => 'hidden',
		'type' => 'upload');
	
	$options[] = array(
		'name' => __('Display Search Form?', 'wpboxes'),
		'desc' => __('Displays the Search Form', 'wpboxes'),
		'id' => 'wpboxes_showsearchform',
		'type' => 'select',
		'std' => 'show',
		'class' => 'mini',
		'options' => $showhide);
	/* Homepage Settings */
	$options[] = array(
		'name' => __('Homepage', 'wpboxes'),
		'type' => 'heading');
		
	$options[] = array(
		'name' => __('Featured Posts Settings', 'wpboxes'),
		'desc' => __('Select the Category for Featured Posts (Slider)', 'wpboxes'),
		'id' => 'wpboxes_fpc',
		'type' => 'select',
		'std' => '',
		'class' => 'mini',
		'options' => $featured_categories);
		
	$options[] = array(
		'desc' => __('The Number of Posts you want to slide', 'wpboxes'),
		'id' => 'wpboxes_nsp',
		'class' => 'mini',
		'std' => '10',
		'type' => 'text');
		
	$options[] = array(
		'desc' => __('Default Slider Image URL for Homepage. Make sure it\'s exactly 730x300 pixels in size.', 'wpboxes'),
		'id' => 'wpboxes_dsi',
		'class' => 'mini',
		'std' => get_template_directory_uri() . '/images/slider.jpg',
		'type' => 'text');

	$options[] = array(
		'name' => __('Sticky Post Settings', 'wpboxes'),
		'desc' => __('Sticky Post Content Length. (Only the latest sticky post will showup if you have any)', 'wpboxes'),
		'id' => 'wpboxes_spcl',
		'class' => 'mini',
		'std' => '80',
		'type' => 'text');		
		
	$options[] = array(
		'name' => __('Latest Posts Settings', 'wpboxes'),
		'desc' => __('Number of posts to appear in homepage. Make sure you enter a integer of 3 (For example: 3, 6, 9, 12 etc) to make it look good.', 'wpboxes'),
		'id' => 'wpboxes_nlp',
		'class' => 'mini',
		'std' => '6',
		'type' => 'text');

	$options[] = array(
		'desc' => __('Enter the number of Words you want in latest posts excerpt', 'wpboxes'),
		'id' => 'wpboxes_lel',
		'class' => 'mini',
		'std' => '55',
		'type' => 'text');
	
	$options[] = array(
		'desc' => __('Default Thumbnail URL for Homepage and Other Pages', 'wpboxes'),
		'id' => 'wpboxes_dtn',
		'class' => 'mini',
		'std' => get_template_directory_uri() . '/images/recent.png',
		'type' => 'text');
	
	/* Single Posts Settings */
	$options[] = array(
		'name' => __('Single Post', 'wpboxes'),
		'type' => 'heading');
		
	$options[] = array(
		'name' => __('Single Posts Settings', 'wpboxes'),
		'desc' => __('Show Post Thumbnail in Headline Area?', 'wpboxes'),
		'id' => 'wpboxes_stn',
		'type' => 'select',
		'std' => 'show',
		'class' => 'mini',
		'options' => $showhide);
		
	$options[] = array(
		'desc' => __('Show Byline?', 'wpboxes'),
		'id' => 'wpboxes_sbl',
		'type' => 'select',
		'std' => 'show',
		'class' => 'mini',
		'options' => $showhide);
		
	$options[] = array(
		'desc' => __('Show Social Sharing Bottons?', 'wpboxes'),
		'id' => 'wpboxes_sss',
		'type' => 'select',
		'std' => 'hide',
		'class' => 'mini',
		'options' => $showhide);

	$options[] = array(
		'desc' => __('Show Author Box?', 'wpboxes'),
		'id' => 'wpboxes_sab',
		'type' => 'select',
		'std' => 'show',
		'class' => 'mini',
		'options' => $showhide);

	$options[] = array(
		'desc' => __('Author Box Position', 'wpboxes'),
		'id' => 'wpboxes_abp',
		'type' => 'select',
		'std' => 'below',
		'class' => 'mini',
		'options' => $abp);	

	$options[] = array(
		'desc' => __('Show Tags?', 'wpboxes'),
		'id' => 'wpboxes_stw',
		'type' => 'select',
		'std' => 'show',
		'class' => 'mini',
		'options' => $showhide);

	$options[] = array(
		'desc' => __('Show Categories?', 'wpboxes'),
		'id' => 'wpboxes_spc',
		'type' => 'select',
		'std' => 'show',
		'class' => 'mini',
		'options' => $showhide);	

	/* Widgets */
	$options[] = array(
		'name' => __('Widgets', 'wpboxes'),
		'type' => 'heading');		
	
	$options[] = array(
		'name' => __('Widget Settings', 'wpboxes'),
		'desc' => __('Show or Hide the Header Laderboard Widget. (728px wide and any height)', 'wpboxes'),
		'id' => 'wpboxes_tw',
		'type' => 'select',
		'std' => 'hide',
		'class' => 'mini',
		'options' => $showhide);	
		
	$options[] = array(
		'desc' => __('Show or Hide the After Post Widget. (728px wide and any height)', 'wpboxes'),
		'id' => 'wpboxes_apw',
		'type' => 'select',
		'std' => 'hide',
		'class' => 'mini',
		'options' => $showhide);

	$options[] = array(
		'desc' => __('Show or Hide the Footer Widget. (728px wide and any height)', 'wpboxes'),
		'id' => 'wpboxes_fw',
		'type' => 'select',
		'std' => 'hide',
		'class' => 'mini',
		'options' => $showhide);		
	
	/* Footer */
	$options[] = array(
		'name' => __('Footer', 'wpboxes'),
		'type' => 'heading');		
	
	$options[] = array(
		'name' => __('Footer Settings', 'wpboxes'),
		'desc' => __('Enable The Widgetized Footer?', 'wpboxes'),
		'id' => 'wpboxes_wf',
		'type' => 'select',
		'std' => 'show',
		'class' => 'mini',
		'options' => $showhide);
		
	$options[] = array(
		'desc' => __('Copyright Text. (For long lines, use a line break.', 'wpboxes'),
		'id' => 'wpboxes_fc',
		'std' => '&copy; <a href="' . site_url() . '" title="' . get_bloginfo('name') . '" >' . get_bloginfo('name') . '</a>, ' . date('Y') . '. All Rights Reserved.',
		'type' => 'textarea');
	
	return $options;
}	

function wpboxes_hide_logo_upload() { ?>

<script type="text/javascript">
jQuery(document).ready(function($) {

	$('#wpboxes_imagelogo').click(function() {
  		$('#section-wpboxes_logo_uploader').fadeToggle(400);
	});

	if ($('#wpboxes_imagelogo:checked').val() !== undefined) {
		$('#section-wpboxes_logo_uploader').show();
	}

});
</script>
<?php } 
add_action('optionsframework_custom_scripts', 'wpboxes_hide_logo_upload');

?>